import { createStore } from 'vuex'
import persist from 'vuex-persistedstate'
export default createStore({
  state: {
    cartList:[], // 购物车的数据
  },
  mutations: {
    addCart(state,val){
      let i = state.cartList.findIndex(item => item.goodId == val.goodId);
      if (i > -1){
        state.cartList[i].number += val.number
        return
      }
      state.cartList.push(val);
    },
     storeAll(){
       
     }
  },
  actions: {
  },
  modules: {
  },
  plugins: [
    new persist({
      storage: window.localStorage,
    }),
  ],
})
